device: gdk_device_list_axes() => gdk_device_get_axis_names()
authorBenjamin Otte <otte@redhat.com>
Sat, 22 Feb 2020 22:31:24 +0000 (23:31 +0100)
committerBenjamin Otte <otte@redhat.com>
Sun, 23 Feb 2020 00:59:26 +0000 (01:59 +0100)
Turn a GList of GdkAtom into a char ** - and rename the function to not
cause problems.

docs/reference/gdk/gdk4-sections.txt
gdk/gdkdevice.c
gdk/gdkdevice.h

index c6814e2c7ccc09e04962e077a42e05c0fd9b8420..bff1aea44c3774c34c9559e1872b1d19d3dde902 100644 (file)
@@ -471,7 +471,7 @@ gdk_device_get_history
 gdk_device_free_history
 GdkTimeCoord
 gdk_device_get_axis
-gdk_device_list_axes
+gdk_device_get_axis_names
 gdk_device_get_axis_value
 gdk_device_get_last_event_surface
 
index 186738cf0424c59e818c3327d2d7510525f4f735..b9d0e47bfe92c44578ae72d9f1c482bdfe2be4ad 100644 (file)
@@ -1081,33 +1081,41 @@ gdk_device_get_n_axes (GdkDevice *device)
 }
 
 /**
- * gdk_device_list_axes:
- * @device: a pointer #GdkDevice
+ * gdk_device_get_axis_names:
+ * @device: a #GdkDevice
  *
- * Returns a #GList of #GdkAtoms, containing the labels for
+ * Returns a null-terminated array of strings, containing the labels for
  * the axes that @device currently has.
+ * If the device has no axes, %NULL is returned.
  *
- * Returns: (transfer container) (element-type GdkAtom):
- *     A #GList of strings, free with g_list_free().
+ * Returns: (nullable) (transfer full): A null-terminated string array,
+ *     free with g_strfreev().
  **/
-GList *
-gdk_device_list_axes (GdkDevice *device)
+char **
+gdk_device_get_axis_names (GdkDevice *device)
 {
-  GList *axes = NULL;
+  GPtrArray *axes;
   gint i;
 
   g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
   g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, NULL);
 
+  if (device->axes->len == 0)
+    return NULL;
+
+  axes = g_ptr_array_new ();
+
   for (i = 0; i < device->axes->len; i++)
     {
       GdkAxisInfo axis_info;
 
       axis_info = g_array_index (device->axes, GdkAxisInfo, i);
-      axes = g_list_prepend (axes, axis_info.label);
+      g_ptr_array_add (axes, g_strdup (axis_info.label));
     }
 
-  return g_list_reverse (axes);
+  g_ptr_array_add (axes, NULL);
+
+  return (char **) g_ptr_array_free (axes, FALSE);
 }
 
 /**
@@ -1119,7 +1127,7 @@ gdk_device_list_axes (GdkDevice *device)
  *
  * Interprets an array of double as axis values for a given device,
  * and locates the value in the array for a given axis label, as returned
- * by gdk_device_list_axes()
+ * by gdk_device_get_axes()
  *
  * Returns: %TRUE if the given axis use was found, otherwise %FALSE.
  **/
index 5520e73dfb6348cbd322784e7d500ea4f4115769..9a2cc758bf729618d47378c3c0f08852af7fb9f8 100644 (file)
@@ -184,7 +184,7 @@ void     gdk_device_free_history (GdkTimeCoord     **events,
 GDK_AVAILABLE_IN_ALL
 gint     gdk_device_get_n_axes     (GdkDevice       *device);
 GDK_AVAILABLE_IN_ALL
-GList *  gdk_device_list_axes      (GdkDevice       *device);
+char **  gdk_device_get_axis_names (GdkDevice       *device);
 GDK_AVAILABLE_IN_ALL
 gboolean gdk_device_get_axis_value (GdkDevice       *device,
                                     gdouble         *axes,